from openai import OpenAI
import os


def get_response():
    client = OpenAI(
        #api_key="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",
        #base_url="https://ffflichun-goldptarmigan.web.val.run/v1"
        api_key="sk-6b44e32c6ce5429dsadasd6a60a72",
        base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    )
    completion = client.chat.completions.create(
        model="qwen-vl-plus",
        messages=[
            {
              "role": "user",
              "content": [
                {
                  "type": "text",
                  "text": "分析这个图片"
                },
                {
                  "type": "image_url",
                  "image_url": {
                    "url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"
                  }
                }
              ]
            }
          ],
        top_p=0.8,
        stream=True,
        stream_options={"include_usage": True}
        )
    for chunk in completion:
      print(chunk.model_dump_json())

if __name__=='__main__':
    get_response()
